package com.yy.pojo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.stereotype.Repository;

import javax.persistence.Column;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * @author YY
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Accessors(chain = true)
public class User implements Serializable {
    private String uid;
    private String uname;
    private String pwd;
    private String urname;
    private String usex;
    private String udpt;
    private String upost;
    private String salt;
    private String email;
    private String phone;

    @TableField(exist = false)
    private List<Role> roles;
    @TableField(exist = false)
    private List<Power> powers;


    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof User)) return false;
        User user = (User) o;
        return Objects.equals(getUid(), user.getUid()) && Objects.equals(getUname(), user.getUname()) && Objects.equals(getPwd(), user.getPwd()) && Objects.equals(getUrname(), user.getUrname()) && Objects.equals(getUsex(), user.getUsex()) && Objects.equals(getUdpt(), user.getUdpt()) && Objects.equals(getUpost(), user.getUpost()) && Objects.equals(getSalt(), user.getSalt()) && Objects.equals(getEmail(), user.getEmail()) && Objects.equals(getPhone(), user.getPhone()) && Objects.equals(getRoles(), user.getRoles()) && Objects.equals(getPowers(), user.getPowers());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getUid(), getUname(), getPwd(), getUrname(), getUsex(), getUdpt(), getUpost(), getSalt(), getEmail(), getPhone(), getRoles(), getPowers());
    }
}
